package com.bw.flinkstreaming.state2.job5;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class AggregatingStateTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);
        DataStreamSource<Tuple2<Long, Long>> sources = env.fromElements(Tuple2.of(100L, 20L), Tuple2.of(101L, 20L), Tuple2.of(102L, 20L), Tuple2.of(100L, 21L), Tuple2.of(100L, 160L),Tuple2.of(100L, 260L),Tuple2.of(102L, 20L),Tuple2.of(102L, 20L));
        sources.keyBy(0).flatMap(new AggregatingStateExe()).print();
        env.execute("AggregatingStateTest");
    }
}
